#ifndef STAIR_H
#define STAIR_H

#include "AnimatorHolder.h"
#include "MovingPathAnimation.h"
#include "MovingPathAnimator.h"
#include "Step.h"
#include "Sprite.h"
#include <vector>
#include <string>

class Stair {
protected:
	std::vector<Step*> steps; //the steps of the stair
	void* bottom;			//the bottom platform
	void* top;				//the top platform
	MovingPathAnimation *up, *down;
	MovingPathAnimator *animator;
	std::string stairType; 

public:
	Stair(void *_top, void *_bottom, const std::vector<Step*> &_steps, 
		MovingPathAnimation *_up, MovingPathAnimation *_down, MovingPathAnimator *_animator,
		std::string _stairType): 
	  top(_top), bottom(_bottom), steps(_steps), up(_up), down(_down), animator(_animator),
	  stairType(_stairType) {};
	~Stair(void) {};
	virtual void AlignUp(Sprite* s) = 0;
	virtual void AlignDown(Sprite* s)  = 0;
	virtual void AnimateUp(Sprite* s)  = 0;
	virtual void AnimateDown(Sprite* s)  = 0;

	
	void SetupAnimation(void) { AnimatorHolder::MarkAsRunning(animator); }
		
	void* GetTopPlatform(void) { return top; }

	void* GetBottomPlatform(void) { return bottom; }

	Step* GetTopStep(void) { return steps.back(); }

	Step* GetBottomStep(void) { return steps.front(); }

	Step* GetUpStep(Step* step) {
		unsigned int i;

		if(step == GetTopStep()) return step;

		for(i=1; i < steps.size(); ++i)
			if(steps.at(i-1) == step)
				return steps.at(i);
		
		return NULL;
	}

	Step* GetDownStep(Step* step) {
		unsigned int i;

		if(step == GetBottomStep()) return NULL;

		for(i=steps.size()-2; i >= 0; i--)
			if(steps.at(i+1) == step)
				return steps.at(i);
		
		return NULL;
	}

	std::string GetStairType(void) { return stairType; };

};

#endif
